<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>员工管理</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="__INDEX__/js/mui.min.js"></script>
	    <link href="__INDEX__/css/mui.min.css" rel="stylesheet"/>
		<link rel="stylesheet" href="__INDEX__/store/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/store/css/newsj.css" />
	</head>
    <style>
    	.syyinfo{
    		position: absolute; 
    		top: 18px;
    	}
    	p{
    		margin-left: 80px;
    	}
    	.sjindexcon{
    		height: auto;
    	}
    </style>
	<body class="sjindexcon">
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">员工管理</h1>
		</header>
		<div class="mui-content sjindexcon">
			<input type="hidden" id="page" value="1" /> 
			<ul class="syy_list">
 
			</ul>
		<a href="employee_memadd.html?agent_id={$agent_id}">
		    <div style="position:fixed;bottom:0;width: 100%;background-color: #1DAA39;height: 45px;line-height: 45px;color: #fff;font-size: 20px;text-align: center;">添加员工</div>
		</a>
		</div>
		<div class="mask" style="display: none;"></div>
		<div class="tanchubox" style="display: none;">
			<div class="syytc_icon"><img src="__INDEX__/store/images/icon_jth.png"></div>
			<div class="syytc_tip">删除该员工后，<br/>所关联的收款二维码即刻失效！</div>
			<div class="syytc_zd">确认删除？</div>
			<button type="button" class="tanc_btn syytc_btn">确定</button>
			<div class="close" onclick="$('.tanchubox').hide()"><span class="mui-icon mui-icon-closeempty"></span></div>
		</div>
	</body>
</html>
<script type="text/javascript" src="__INDEX__/store/js/jquery.min.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/castapp.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/layer/layer.min.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/picker.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/city.data-3.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/bootstrap.min.js"></script> 
<script> 
	$.ajax({
		type: "post",
		data: {
			page: $("#page").val()
		},
		url: "{:url('store/agent/ssy_list')}",
		success: function(data) {
			var list = data.list;
			var html = "";
			if(list != '') {
				for(var i = 0; i < list.length; i++) {
					var log = list[i];
					var type = '';
					var logo = '';
					if(log.ctype == 1){
						type= '员工';
					}else{
						type= '店长';
					} 
					if(log.logo == '' || log.logo == null){
						logo = '__INDEX__/store/images/syyimg.jpg';
					}else{
						logo = log.logo;
					}
					
					html += '<li>'
					    +"<a href='employee_memedit?clerk_id="+log.id+"'>"
					    +"<div class='syyimg'><img src='"+logo+"'></div>"
					    +"<div class='syyinfo'>"
					    +"<p>姓名："+log.name+"</p>"
					    +"<p>职位："+type+"</p>"
					    +"<p>员工会员ID："+log.user_id+"</p>"
					    +"<p>员工手机号："+log.mobile+"</p>"
					    +"</div>" 
					    +"<a class='syygl_btn' onclick='edit("+log.id+")'>删除员工</a>" 
					    +"</a>"
						+'</li>';
				}
			} else {
				html="<img style='width: 360px;height: 214px;margin-top: 80px;' src='__INDEX__/store/images/none_syy.jpg'/>";
			}
			$(".syy_list").html(html);

		}
	});
	
	$(window).scroll(function(){
		var scrollTop = $(window).scrollTop();       //滚动条高度
		var bodyheight = $(document).height();         //文档的高度
		var windowheight = window.innerHeight;	//$(window).height();              //当前窗体的高度
		if((bodyheight - windowheight - scrollTop) == 0){
			$.ajax({
			type:"post",
			data:{
				page:parseFloat($("#page").val())+1
			},
			url:"{:url('store/agent/ssy_list')}",
			success:function(data){	
				var list=data.list;
				var html="";
				if(list){
					$("#page").val(parseFloat($("#page").val())+1);
					for(var i = 0; i < list.length; i++) {
						var log = list[i];
						var type = '';
						var logo = '';
						if(log.ctype == 1){
							type= '员工';
						}else{
							type= '店长';
						}
					if(log.logo == '' || log.logo == null){
						logo = '__INDEX__/store/images/syyimg.jpg';
					}else{
						logo = log.logo;
					}
					
					html += '<li>'
					    +"<a href='employee_memedit?clerk_id="+log.id+"'>"
					    +"<div class='syyimg'><img src='"+logo+"'></div>"
					    +"<div class='syyinfo'>"
					    +"<p>姓名："+log.name+"</p>"
					    +"<p>职位："+type+"</p>"
					    +"<p>员工会员ID："+log.user_id+"</p>"
					    +"<p>员工手机号："+log.mobile+"</p>"
					    +"</div>" 
					    +"<a class='syygl_btn' onclick='edit("+log.id+")'>删除员工</a>" 
					    +"</a>"
						+'</li>';
				}
				}else{
					html="已经到最后";
				}
				$(".syy_list").append(html);
				
			}
		});
		
		}				
	})
	
		//删除员工
	function edit(id){ 
        $(".tanchubox").removeAttr("style");
        edit2(id);
	}
		
	function edit2(id){
		$('.tanc_btn').click(function() {
			$.ajax({
				url: "{:url('agent/del_emp')}",
				data: {
					emp_id: id
				},
				success: function(data) {
					if(data.code == 200) {
						layer.msg(data.msg, {
							time: 2000
						}, function() {
							location.href = "{:url('agent/employeemage')}";
						});
					} else {
						layer.msg(data.msg);
					}
				}
			});
		})
	}	
</script>